package com.lzx.activity.controller.web;

import com.lzx.activity.entity.VoucherOrder;
import com.lzx.activity.service.VoucherOrderService;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/activity/voucherOrder/web")
public class WebVoucherOrderController {
    @Resource
    private VoucherOrderService voucherOrderService;

    //MQ服务保存订单和扣减库存
    @PostMapping("/saveOrderAndReduceStock")
    public String saveOrderAndReduceStock(@RequestBody VoucherOrder voucherOrder){
        return voucherOrderService.saveOrderAndReduceStock(voucherOrder);
    }

    //优惠券秒杀
    @PostMapping("/voucherSecKill/{id}/{userId}")
    public R voucherSecKill(@PathVariable Long id, @PathVariable Long userId) {
        return voucherOrderService.voucherSecKill(id, userId);
    }
}
